import com.demo.mapper.AccountMapper;
import com.demo.pojo.Account;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

/**
 * @ClassName Demo
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/1 11:46
 * @Version 1.0
 **/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:bean.xml")
public class Demo {
    @Autowired
    JdbcTemplate template;
    @Test
    public void testTemplate(){
//        template.execute("insert into account(name,money) values('Naro',100.0)");
        List<Account> list = template.query("select * from account",new BeanPropertyRowMapper<Account>(Account.class));
        list.forEach(o-> System.out.println(o));
        Long aLong = template.queryForObject("select count(*) from account ", Long.class);
        System.out.println(aLong);
    }
}
